package drds.server.sqlparser.sqlobject.expression;

import drds.server.sqlparser.visitor.Visitor;

/**
 * 
 * @author 曹正辉<330937205@qq.com>
 * 
 */
public class Not extends AbstractExpression {

	public Expression expression;

	public Not() {

	}

	public Not(Expression expression) {
		this.expression = expression;
	}

	public void setExpression(Expression expression) {
		this.expression = expression;
	}

	public Expression getExpression() {
		return this.expression;
	}

	protected void accept0(Visitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, this.expression);
		}

		visitor.endVisit(this);
	}

	@Override
	public void output(StringBuffer sb) {
		sb.append(" not ");
		this.expression.output(sb);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((expression == null) ? 0 : expression.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null) {
			return false;
		}
		if (getClass() != o.getClass()) {
			return false;
		}
		Not other = (Not) o;
		if (expression == null) {
			if (other.expression != null) {
				return false;
			}
		} else if (!expression.equals(other.expression)) {
			return false;
		}
		return true;
	}
}
